package com.kingdee.Utils;

import com.kingdee.model.Contacts;
import com.sun.org.apache.xpath.internal.SourceTree;

import javax.xml.transform.Source;

/**
 * Created by Administrator on 2016/12/28.
 */
public class TimeTransfer {
    public static int string2Int(String timeString){
        int worktime = 0;
        String[] stringList = timeString.split(Contacts.timeSplit);
        String hour = stringList[0];
        String minites = stringList[1];

        worktime = Integer.valueOf(hour) * 60 + Integer.valueOf(minites);
        return worktime;
    }

    public static String int2String(int worktime){
        String worktimeString = null;

        int hour = worktime/Contacts.timeStandart;
        int minites = worktime%Contacts.timeStandart;

        worktimeString = timeFormatted(hour) + Contacts.timeSplit + timeFormatted(minites);
        System.out.println("您今天一共工作了" + hour + "小时" + minites + "分钟！" );
        return worktimeString;
    }

    public static String timeFormatted(int time){
        String afterFormatted = String.valueOf(time);
        if(time < Contacts.timeFormatted){
            afterFormatted = Contacts.zeroString + afterFormatted;
        }
        return afterFormatted;

    }

}
